Skip to content

feat(origin): run wrangler via bunx/npx when not on PATH#5

Merged
n1rna merged 1 commit into
mainfrom
feat/wrangler-bunx-npx-fallback
Jul 3, 2026
Merged

feat(origin): run wrangler via bunx/npx when not on PATH#5
n1rna merged 1 commit into
mainfrom
feat/wrangler-bunx-npx-fallback

Conversation

@n1rna

@n1rna n1rna commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

wrangler is frequently installed as a project dependency (via npm/bun) rather than globally, so ee push and ee auth would fail with 'wrangler' CLI not found on PATH even though the project could run it perfectly well. This adds an automatic fallback: when a tool isn't on PATH, ee runs it through a JavaScript package runner — bunx wrangler or npx wrangler — which resolves the project-local install (node_modules/.bin) or fetches it on the fly.

Behavior

Resolution order for wrangler:

  1. wrangler on PATH → used directly (unchanged behavior)
  2. else bunx wrangler if bunx is available
  3. else npx -y wrangler if npx is available
  4. else a clear error pointing at both the install docs and the bunx/npx fallback

gh is unaffected — it's a native binary with no npm runner, so it has no fallback.

Implementation

  • internal/origin/toolcheck.go: new ResolveTool / ToolCommand centralize resolution. CheckTool and RunCommand now go through it. lookPath is an injectable indirection over exec.LookPath for deterministic tests.
  • internal/origin/cloudflare.go: secret push (bulk and put) now build the command via ToolCommand("wrangler", ...) instead of a hardcoded exec.Command("wrangler", ...).
  • Docs: README note + ee-usage skill note describing the fallback.

Tests / verification

  • Unit tests (toolcheck_test.go): PATH-first, bunx fallback, npx fallback, bunx-over-npx ordering, no-runner error, gh has no fallback, ToolCommand argv, and resolver-vs-exec error. go test ./... → all pass.
  • End-to-end: with a fake bunx on PATH and wrangler absent, ee auth wrangler resolves to bunx wrangler whoami and reports authenticated; with nothing available it prints the improved error mentioning bunx/npx.
  • golangci-lint run → 0 issues; gofmt/golines clean.

🤖 Generated with Claude Code

wrangler is often installed as a project dependency rather than globally,
so 'ee push'/'ee auth' failed with 'not found on PATH' even though the
project could run it. Add a tool resolver that prefers a binary on PATH
and falls back to a JavaScript package runner (bunx, then npx -y) for
npm-based tools like wrangler, resolving the project-local install or
fetching on the fly.

- ResolveTool/ToolCommand centralize resolution; CheckTool and RunCommand
  now go through it, and cloudflare push uses ToolCommand
- Improved not-found message points at both the install docs and the
  bunx/npx fallback
- Unit tests cover PATH-first, bunx/npx fallback and ordering, and the
  no-runner error (lookPath is injectable for deterministic tests)
- Document the fallback in the README and the ee-usage skill

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@n1rna
n1rna merged commit f3c6aa7 into main Jul 3, 2026
3 checks passed
n1rna added a commit that referenced this pull request Jul 3, 2026
Adds the bunx/npx fallback for running wrangler when it is not on PATH
(#5) since v0.10.0. Bump the version string, Makefile default, and README
badge accordingly.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant